package com.rjwh.dingdong.client.mvp.model.impl;

import com.aishua.lib.task.AsResult;
import com.rjwh.dingdong.client.constant.NetConstant;
import com.rjwh.dingdong.client.mvp.BaseModel;
import com.rjwh.dingdong.client.mvp.BasePresenter;
import com.rjwh.dingdong.client.mvp.model.IMathGameIslandsListModel;
import com.rjwh.dingdong.client.network.HttpWebService;
import com.rjwh.dingdong.client.network.HttpWebServiceCallBack;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Kay
 * @ClassName MathGameIslandsListModel
 * @Description
 * @date 2016-8-31
 * @history 2016-8-31 author: description:
 */
public class MathGameIslandsListModel extends BaseModel implements IMathGameIslandsListModel, HttpWebServiceCallBack {

    public MathGameIslandsListModel(BasePresenter basePresenter) {
        super(basePresenter);
    }

    /**
     * 获取教材所有游戏
     *
     * @param bookid    游戏id
     * @param pageindex 页码
     */
    @Override
    public void doGetBookIslandGame(int bookid, String packageversion, int pageindex, boolean isRefresh) {
        Map<String, String> getBookIslandGameParams = new HashMap<>();
        getBookIslandGameParams.put("pageindex", String.valueOf(pageindex));
        getBookIslandGameParams.put("bookid", String.valueOf(bookid));
        getBookIslandGameParams.put("packageverson", packageversion);
        HttpWebService.getDataFromServer(NetConstant.GETBOOKISLANDGAMEBYVERSION, getBookIslandGameParams, isRefresh, this);
    }

    @Override
    public void onServerDataAcquired(int businessType, AsResult mAsResult, boolean isRefresh) {
        if (getBasePresenter() != null) {
            getBasePresenter().onServerDataAcquired(businessType, mAsResult, isRefresh);
        }
    }

}
